import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PaymentVO, PaymentForm, PaymentQuery } from '@/api/goods/payment/types';

/**
 * 查询回款单列表
 * @param query
 * @returns {*}
 */

export const listPayment = (query?: PaymentQuery): AxiosPromise<PaymentVO[]> => {
  return request({
    url: '/order/payment/list',
    method: 'get',
    params: query
  });
};
/**
 * 查询回款单列表
 * @param query
 * @returns {*}
 */

export const getPaymentNumber = (): AxiosPromise<PaymentVO[]> => {
  return request({
    url: '/order/payment/getPaymentNumber',
    method: 'get'
  });
};
/**
 * 查询回款明细
 * @param query
 * @returns {*}
 */

export const getPaymentDetail = (params): AxiosPromise<any[]> => {
  return request({
    url: '/order/paymentDetail',
    method: 'get',
    params: params
  });
};

/**
 * 查询回款单详细
 * @param id
 */
export const getPayment = (id: string | number): AxiosPromise<PaymentVO> => {
  return request({
    url: '/order/payment/' + id,
    method: 'get'
  });
};

/**
 * 新增回款单
 * @param data
 */
export const addPayment = (data: PaymentForm) => {
  return request({
    url: '/order/payment',
    method: 'post',
    data: data
  });
};
/**
 * 新增回款单
 * @param data
 */
export const auditPayment = (data: any) => {
  return request({
    url: '/order/payment/audit',
    method: 'post',
    data: data
  });
};
/**
 * 新增回款单
 * @param data
 */
export const unAuditPayment = (data: any) => {
  return request({
    url: '/order/payment/unAudit',
    method: 'post',
    data: data
  });
};

/**
 * 修改回款单
 * @param data
 */
export const updatePayment = (data: PaymentForm) => {
  return request({
    url: '/order/payment',
    method: 'put',
    data: data
  });
};

/**
 * 删除回款单
 * @param id
 */
export const delPayment = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/payment/' + id,
    method: 'delete'
  });
};

/**
 * 查询回款统计
 * @param query
 * @returns {*}
 */

export const getPaymentCount = (query?: PaymentQuery): AxiosPromise<PaymentVO[]> => {
  return request({
    url: '/order/payment/listCount',
    method: 'get',
    params: query
  });
};
export default {
  list: listPayment,



  get: getPayment,


  add: addPayment,

  update: updatePayment,
  del: delPayment,
  getPaymentNumber,
  getPaymentCount,
  auditPayment,
  unAuditPayment,
  getPaymentDetail
}